from flask import Blueprint, request, jsonify
from app.services.sport_services import SportService

bp = Blueprint('sport_routes', __name__)
sport_service = SportService()


@bp.route('/mets', methods=['GET'])
def get_all_mets():
    """获取所有 MET 信息"""
    mets = sport_service.getAllMets()
    return jsonify(mets), 200  # 返回所有 MET 信息，状态码 200


@bp.route('/<int:user_id>/mets', methods=['GET'])
def get_user_mets(user_id):
    """获取指定用户的 MET 信息，并按运动记录次数排序"""
    mets = sport_service.getUserMets(user_id)
    return jsonify(mets), 200  # 返回排序后的 MET 信息，状态码 200